#ifndef UCALENDARWIDGET_H
#define UCALENDARWIDGET_H

#include "utkwidget_export.h"

#include <QCalendarWidget>

class UCalendarWidgetPrivate;
class UTKWIDGET_EXPORT UCalendarWidget : public QCalendarWidget
{
    Q_OBJECT
public:
    explicit UCalendarWidget(QWidget* parent = nullptr);
    ~UCalendarWidget();

    void setTimeVisible(bool visible);

    void setCurrentDateTime();

    void setDateTime(const QDateTime &time);

    void updateCells();

    void startTime();

    void stopTime();

protected:
    void paintEvent(QPaintEvent*) override;

    void changeEvent(QEvent* event) override;

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
    void paintCell(QPainter* painter, const QRect &rect, const QDate &date) const override;
#else
    void paintCell(QPainter* painter, const QRect &rect, QDate date) const override;
#endif

    void hideEvent(QHideEvent* event) override;

signals:
    void confirmClicked();

    void selectDateTime(const QDateTime &time);

    void closed();

private slots:
    void onCurrentPageChanged(int year, int month);

    void onDateChanged();

private:
    QScopedPointer<UCalendarWidgetPrivate> d_ptr;
    Q_DISABLE_COPY(UCalendarWidget)
    Q_DECLARE_PRIVATE_D(d_ptr, UCalendarWidget)
};

#endif // UCALENDARWIDGET_H
